#-*- coding: utf-8 -*-
"""Вычленить все команды из куска исходника mimeTex"""

fname = "commands_raw.txt"
fname_out = "intelli_tex.txt"

items = set()
for line in file(fname).readlines():
	startpos = line.find ('"\\\\')
	if startpos == -1:
		continue
	
	endpos = line.find ('"', startpos + 1)
	if endpos == -1:
		continue
	
	#print line[startpos + 1: endpos]
	#print endpos
	
	item = line[startpos + 2: endpos].strip()
	#item.replace ("\\\\", "\\")
	if item.find ("\\", 1) != -1:
		continue
	
	if len (item) >= 2:
		items.add (item + "\n" )


items_list = list (items)
items_list.sort()
file (fname_out, "w").writelines (items_list)